package cn.com.dpc.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import cn.com.dpc.R;
import cn.com.dpc.bean.Column;

public class MixAdapter extends ColumnAdapter {
	private Context context;

	public MixAdapter(Context context) {
		this.context = context;
	}

	private int[] number = {};

	private int[] type = {};

	private String[] url = {};
	private String[] texts = {};

	@Override
	public void setNumber(int[] number) {
		this.number = number;
	}

	@Override
	public void setType(int[] type) {
		this.type = type;
	}

	@Override
	public void setUrl(String[] url) {
		this.url = url;
	}

	@Override
	public void setTexts(String[] texts) {
		this.texts = texts;
	}

	@Override
	public int[] getNumber() {
		return number;
	}

	@Override
	public int[] getType() {
		return type;
	}

	@Override
	public String[] getUrl() {
		return url;
	}

	@Override
	public String[] getTexts() {
		return texts;
	}

	// get the number
	@Override
	public int getCount() {
		return url.length;
	}

	@Override
	public Object getItem(int position) {
		return position;
	}

	// get the current selector's id number
	@Override
	public long getItemId(int position) {
		return position;
	}

	// create view method
	@Override
	public View getView(int position, View view, ViewGroup viewgroup) {
		Column wrapper;
		if (view == null) {
			wrapper = new Column();
			LayoutInflater inflater = LayoutInflater.from(context);
			view = inflater.inflate(R.layout.fav_item, null);
			view.setTag(wrapper);
			// view.setPadding(15, 15, 15, 15); // 每格的间距
		} else {
			wrapper = (Column) view.getTag();
		}

		wrapper.type = (TextView) view.findViewById(R.id.type);
		wrapper.type.setText(String.valueOf(type[position]));
		wrapper.number = (TextView) view.findViewById(R.id.number);
		wrapper.number.setText(String.valueOf(number[position]));
		wrapper.url = (TextView) view.findViewById(R.id.url);
		wrapper.url.setText(url[position]);
		wrapper.textView = (TextView) view.findViewById(R.id.fav_title);
		wrapper.textView.setText(texts[position]);

		return view;
	}
}
